package com.cjyd.hrjb.model.enums;

import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.enums.IEnum;
import com.cjyd.hrjb.exception.ServiceException;
import com.cjyd.hrjb.utils.ResultCode;
import com.fasterxml.jackson.annotation.JsonCreator;

/**
 * Created fei wo by 2020/4/5
 */
public enum AdminRole implements BaseEnum<Integer> {
    GENERAL(1,"普通管理员"), SUPPER_ADMIN(2,"超级管理员");

    private Integer val;
    private String desc;

    AdminRole(Integer val, String desc) {
        this.val = val;
        this.desc = desc;
    }


    @Override
    public Integer getValue() {
        return this.val;
    }

    @Override
    public String getDesc() {
        return this.desc;
    }

    @JsonCreator
    public static AdminRole getAdminRole(Integer val) {
        for (AdminRole role : values()) {
            if (ObjectUtil.equal(role.val, val)) {
                return role;
            }
        }
        throw new ServiceException(ResultCode.ENUM_PARSE_EXCEPTION);
    }
}
